package com.yuntsg.nnsfcp.controller.back;


import com.yuntsg.nnsfcp.common.beans.ResultBean;
import com.yuntsg.nnsfcp.common.utils.UserUtil;
import com.yuntsg.nnsfcp.front.mapper.EmployeeMapper;
import com.yuntsg.nnsfcp.service.CommonService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;


@RestController
@Slf4j
//@Api(value = "这是控制台控制器主要是共用方法", tags = "主要的控制台")
@RequestMapping("/console")
public class WorkbenchController {

    @Resource
    EmployeeMapper employeeMapper;

    @Resource
    CommonService commonService;

    @Resource
    UserUtil userUtil;


    @GetMapping("/getuser")
    //@ApiOperation(value = "获取当前登录用户信息")
    public ResultBean<Object> getuser() {
        Map map = new HashMap();
        String roleName = null;
        String userName = null;
        Integer type = userUtil.gettype();
        try {
            roleName = commonService.getRoleNameByUid(userUtil.getBackUserInfo().getId());
            userName = employeeMapper.selectById(userUtil.getBackUserInfo().getId()).getUserName();
        } catch (Exception e) {
        }
        map.put("role", roleName);
        map.put("name", userName);
        map.put("type", type);
        return new ResultBean<>(map);
    }


}
